﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Modularity;

namespace Xms.Abp.Modularity;

public abstract class XmsModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        var serviceProvider = context.Services.BuildServiceProvider();
        var logger = serviceProvider.GetRequiredService<ILogger<XmsModule>>();
        logger.LogTrace("Configuring services start:" + GetType().FullName);
        base.PreConfigureServices(context);
    }

    public override void PostConfigureServices(ServiceConfigurationContext context)
    {
        base.PostConfigureServices(context);
        var serviceProvider = context.Services.BuildServiceProvider();
        var logger = serviceProvider.GetRequiredService<ILogger<XmsModule>>();
        logger.LogTrace("Configuring services will end:" + GetType().FullName);
    }

    public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
    {
        var logger = context.ServiceProvider.GetRequiredService<ILogger<XmsModule>>();
        logger.LogTrace("Initialization module start:" + GetType().FullName);
        base.OnPreApplicationInitialization(context);
    }

    public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
    {
        base.OnPostApplicationInitialization(context);
        var logger = context.ServiceProvider.GetRequiredService<ILogger<XmsModule>>();
        logger.LogTrace("Initialization module will end:" + GetType().FullName);
    }
}

